package com._system._g;

import java.util.Map;

import com.laymi.common.model.GTable;
import com.jfinal.kit.JMap;
import com.jfinal.kit.Kv;
import com.jfinal.kit.Ret;
import com.jfinal.plugin.activerecord.Db;
import com.laymi.common._util.SqlKit;
import com.laymi.common._util.SqlUtil;

/**
 * GTableService
 */
public class GTableService {
	
	public static final GTableService me =new GTableService();
	private final GTable dao = new GTable().dao();
	
	/**
	 * 查询Tables
	 * @param map
	 * @param pageNumber
	 * @param pageSize
	 * @return
	 */
	public Kv searchPage(Map<String, String[]> map,Integer pageNumber,Integer pageSize){
		Kv jmap = SqlUtil.searchPage(new GTable(), map,"*",pageNumber , pageSize);
		return jmap;
	}
	
	/**
	 * 删除一个
	 * @return 
	 */
	public boolean delOne( String id) {
		return Db.deleteById("g_table", id);
	}
	
	/**
	 * 批量删除
	 */
	public void delAll(String ids) {
		if (ids!=null&&ids.split(",").length > 0) {  // idList 有可能为空，不加判断会出异常
			StringBuilder sql = new StringBuilder("delete from g_table where id in");
			SqlKit.joinIds2(ids.split(","), sql);
			Db.update(sql.toString());
		}
	}
	
	/**
	 * 根据id查询
	 */
	public GTable findById(String id) {
		return dao.findById(id);
	}
	

}